package com.jsp.controller;

import com.jsp.pojo.Users;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zc
 * @version 1.0
 * @date 2021/8/26 16:20
 */
@Controller
public class UserController {

    /**
     * 处理请求， 产生数据
     */
    //http://localhost:8080/showUser
    @RequestMapping("/showUser")
    public String showUser(Model model){
        List<Users> list = new ArrayList<>();
        list.add(new Users(1,"张三",20));
        list.add(new Users(2,"李四",22));
        list.add(new Users(3,"王五",24));

        //需要一个 Model 对象
        model.addAttribute("list",list);
        //跳转视图
        return "userList";
    }
}
